SoX Examples

This is a cheat sheet of examples using SoX to do various common sound file conversions.

The core problem is that you need a rule-based inferencing system in order to say "take any old sound file and convert it to this format". Nobody has done this yet for SoX.

Notes

The SUN examples all assume the old SUN voice-quality 8khz u-law hardware. If the .AU file doesn't have a proper header, you'll need the second command line. If you don't want the old format, you can remove the "-r 8012 -U -b" in front of "file.au" when converting TO SUN .au files. Note that you'll need newer SUN sound hardware to successfully play these files.

SUN Sparc-1, Sparc-2, Sparcstation SLC/IPC and ELC are "old" and only have 8-bit hardware. If it doesn't say "CD-quality", it's the old stuff.

VOC has a similar problem. All VOC files have a correct header, but older hardware (and software) only knows about samples made of unsigned bytes. VOC files come from the Sound Blaster and compatible cards on the IBM PC. These cards can play many sample rates; not quite a continuous spectrum but close enough.

The Mac sound hardware traditionally has been capable of sample rates 5012, 1025, and 22050, but only with unsigned bytes. Recent models support CD-quality sound.

Usage examples

SUN .au to Mac .snd:
sox file.au -r 11025 -t ub file.snd
or:
sox -t ul -r 8012 file.au -r 11025 -t ub file.snd

When you copy the file to the Mac, you'll have to set the sample rate by hand.

Mac .snd to SUN .au
sox -r 11025 -t ub file.snd -r 8012 -U -b file.au

The Mac file might also be at sample rates 5012, 22050, or 44100.

PC .voc to SUN .au
sox file.voc -r 8012 -U -b file.au

SUN .au to PC .voc
sox file.au file.voc
or:
sox -r 8012 -t ul file.au file.voc

SUN .au to WAV, without clipping
sox file.au -s -w file.wav
or:
sox -t ul -r 8012 file.au -s -w file.wav

WAV to SUN .au
sox file.wav -r 8012 -U -b file.au

WAV to VOC
sox file.wav -u -b file.voc

VOC to WAV
sox file.voc file.wav

Any file to SUN .au
sox -t auto file.X -c 1 -t aiff - | sox -t aiff - -r 8000 -U -b -t au file.au

Just convert file format without making a disk file. For example, convert input stream in AIFF format to output stream in WAV format:
sox -t aiff - -t wav -
Some people put this kind of command in scripts.

Good luck!

This page was created by

Lance Norskog <thinman@meer.net>

Return to Welcome Home Page or Continue to Browse